<template>
  <div>
    <el-card class="box-card myNotify">
      <div slot="header" class="clearfix">
        <span class="title">公告通知</span>
      </div>
      <div class="scrolling-text">
        <p v-html="content" class="text"></p>
      </div>
    </el-card>
    <el-carousel :interval="4000" type="card" height="340px">
      <el-carousel-item v-for="item in images" :key="item">
        <el-image :src="item"></el-image>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>
<script>
export default {
  name: "Show",
  data() {
    return {
      images: [
        require("../assets/carousel-1.png"),
        require("../assets/carousel-2.png"),
        require("../assets/carousel-3.png"),
      ],
      notify: "公告通知",
      content: ""
    }
  },
  created() {
    this.init();
  },
  methods: {
    //初始化公告通知
    init() {
      this.$http.post("/aboutus/selectByName?name=" + this.notify).then((res => {
        if (res.data.code === 200) {
          this.content = res.data.data.about;
        } else {
          this.content = "暂无通知";
        }
      }), errorMsg => {
        this.$message({
          message: errorMsg,
          type: 'error'
        });
      });
    }
  }
}
</script>

<style scoped>
.myNotify {
  margin: 10px 20px 35px;
}

.title {
  font-weight: bold;
  font-size: 20px;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.scrolling-text {
  overflow: hidden;
  white-space: nowrap;
  margin-bottom: 10px;
}

.text {
  animation: scroll 20s linear infinite;
}

@keyframes scroll {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-100%);
  }
}
</style>